import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { AdminUser } from 'src/db/schemas/admin/admin-user.schema';

@Injectable()
export class AuthService {
	constructor(
		private readonly jwtService: JwtService
	) {}

	async createToken(user: AdminUser) {
		const payload = {
			date: Date.now(),
			_id: user._id,
			userType: user.userType,
			access: user.access,
		};
		return {
			token: this.jwtService.sign(payload),
		};
	}
}
